//
//  FourthViewController.m
//  UI12_homework_2
//
//  Created by dllo on 15/11/10.
//  Copyright (c) 2015年 ZKJ. All rights reserved.
//

#import "FourthViewController.h"

@interface FourthViewController ()

@end

@implementation FourthViewController

- (void)dealloc {
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor cyanColor];
    self.title = @"第四页";
    
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeSystem];
    button1.frame = CGRectMake(0, 0, 100, 100);
    button1.backgroundColor = [UIColor purpleColor];
    [button1 addTarget:self action:@selector(button1DidPress:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button1];
    
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeSystem];
    button2.frame = CGRectMake(200, 0, 100, 100);
    button2.backgroundColor = [UIColor purpleColor];
    [button2 addTarget:self action:@selector(button2DidPress:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button2];
    
    UIButton *button3 = [UIButton buttonWithType:UIButtonTypeSystem];
    button3.frame = CGRectMake(0, 200, 100, 100);
    button3.backgroundColor = [UIColor purpleColor];
    [button3 addTarget:self action:@selector(button3DidPress:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button3];
    
    UIButton *button4 = [UIButton buttonWithType:UIButtonTypeSystem];
    button4.frame = CGRectMake(200, 200, 100, 100);
    button4.backgroundColor = [UIColor purpleColor];
    [button4 addTarget:self action:@selector(button4DidPress:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button4];
    
    
}

- (void)button1DidPress:(UIButton *)sender {
    [UIView animateWithDuration:1.0 animations:^{
        [UIView setAnimationRepeatAutoreverses:YES];
        sender.frame = CGRectMake(200, 200, 100, 100);
    }];
}

- (void)button2DidPress:(UIButton *)sender {
    [UIView animateWithDuration:1.0 animations:^{
        sender.transform = CGAffineTransformRotate(sender.transform, M_PI);
    } completion:^(BOOL finished) {
        NSLog(@"动画结束");
    }];
}

- (void)button3DidPress:(UIButton *)sender {
    [UIView animateWithDuration:1.0 delay:1 options:UIViewAnimationOptionRepeat animations:^{
        sender.center = self.view.center;
    } completion:^(BOOL finished) {
        
    }];
}

- (void)button4DidPress:(UIButton *)sender {
    [UIView animateWithDuration:1.0 delay:0 usingSpringWithDamping:0.1 initialSpringVelocity:0.4 options:UIViewAnimationOptionRepeat animations:^{
        sender.center = self.view.center;
    } completion:^(BOOL finished) {
        
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
